from typing import List, Union
from pydantic import BaseModel


class Song(BaseModel):
    filepath: str
    mime: str
    add_time: str
    hashcode: str
    title: str
    artist: Union[str, None] = None
    album: Union[str, None] = None
    tracknumber: Union[str, None] = None
    year: Union[str, None] = None
    lyrics: Union[str, None] = None
    picture: Union[str, None] = None
    bitrate: int = 0
    frame_rate: int = 0


class LibraryConf(BaseModel):
    basedir: str
    library_path: str
    conf_path: str
    collect_type: int
    audio_pattern: str = "{title} - {artist}"


class LibraryCache(BaseModel):
    songs: List[Song]
    scaning: bool = False


class DashboardConf(BaseModel):
    id: str
    status: int
    status_desc: str
    song_size: int
    library_conf: LibraryConf


class Page(BaseModel):
    page: int
    page_size: int
    total: int
    list: Union[List[Song], None] = None
